package com.gnerv.sylvanas.module.mybatis.extend;

import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.boot.autoconfigure.SqlSessionFactoryBeanCustomizer;

/**
 * @author Gnerv LiGen
 */
public class MybatisSqlSessionFactoryBeanCustomizer implements SqlSessionFactoryBeanCustomizer {

    private final MybatisResourceHandler mybatisResourceHandler;

    public MybatisSqlSessionFactoryBeanCustomizer(MybatisResourceHandler mybatisResourceHandler) {
        this.mybatisResourceHandler = mybatisResourceHandler;
    }

    @Override
    public void customize(SqlSessionFactoryBean sqlSessionFactoryBean) {
        sqlSessionFactoryBean.setMapperLocations(mybatisResourceHandler.build());
    }
}
